#include <iostream>
#include <unordered_set>
#include <vector>

using namespace std;

class Solution {
public:
    int maxNumberOfFamilies(int n, vector<vector<int>>& reservedSeats) {
        unordered_set<uint64_t> seat;
        for (vector<int> reserved_seat : reservedSeats) {
            seat.insert((uint64_t) reserved_seat[0] << 32 | reserved_seat[1]);
        }
        int ans = 0;
        for (uint64_t i = 0; i < n; i++) {
            bool sign = false;
            if (seat.count(i << 32 | 1) == 0 && seat.count(i << 32 | 2) == 0 && seat.count(i << 32 | 3) == 0 && seat.count(i << 32 | 4) == 0) {
                sign = true;
                ans++;
            }
            if (seat.count(i << 32 | 5) == 0 && seat.count(i << 32 | 6) == 0 && seat.count(i << 32 | 7) == 0 && seat.count(i << 32 | 8) == 0) {
                sign = true;
                ans++;
            }
            if (!sign && seat.count(i << 32 | 3) == 0 && seat.count(i << 32 | 4) == 0 && seat.count(i << 32 | 5) == 0 && seat.count(i << 32 | 6) == 0) {
                ans++;
            }
        }
        return ans;
    }
};

